import type { ApiType, personalUser } from 'src/service/api';
import { useWebStore } from 'src/stores/webStore';
import { ref } from 'vue';

export const articleTab = [
  { code: 'create', text: '发布' },
  { code: 'liked', text: '点赞' },
  { code: 'fav', text: '收藏' },
];
export const userTab = [
  { code: 'follow', text: '关注' },
  { code: 'fans', text: '粉丝' },
];

export const followTab = [
  { code: 'tag', text: '标签' },
  { code: 'topic', text: '话题' },
];

export const artHas = (val: string) => {
  return articleTab.filter((i) => i.code == val).length > 0;
};

export const userHas = (val: string) => {
  return userTab.filter((i) => i.code == val).length > 0;
};

export const followHas = (val: string) => {
  return followTab.filter((i) => i.code == val).length > 0;
};

/* 用户信息 */
export const userInfo = ref<ApiType<typeof personalUser>['Return']>();

/* 刷新用户信息 */
export const refreshUserInfo = () => {
  const webStore = useWebStore();
  webStore.refreshUserInfo().then(() => {
    userInfo.value = webStore.userInfo;
  });
};

export const followDig = ref(false);
